var chartTable={
	drawTable : function(locationName,colNames,dataRowNames,tableData,tableDataHints,showTable,multiplier){
		if(showTable){
			var colNum = colNames.length;
			var dataRowNum = dataRowNames.length;
			var table = document.createElement("table");
			
			//创建thead
			var thead = document.createElement("thead");
			thead.setAttribute("id","charttable_head");
			var tr = document.createElement("tr");
			for(var i=0;i<colNum;i++){
				var td = document.createElement("td");
				td.appendChild(document.createTextNode(colNames[i]));
				tr.appendChild(td);
			}
			thead.appendChild(tr);
			
			//创建tbody
			var tbody = document.createElement("tbody");
			tbody.setAttribute("id","charttable_body");
			for(var i=0;i<dataRowNum;i++){
				var tr = document.createElement("tr");
				for(var j=0;j<colNum;j++){
					var td = document.createElement("td");
					if(j==0){
						td.appendChild(document.createTextNode(dataRowNames[i]));
					}else{
						var text = tableData[i][j-1];
						if (typeof(tableDataHints[i][j-1]) != "undefined") {
							text = text + tableDataHints[i][j-1];
						}
						td.appendChild(document.createTextNode(text));
					}
					tr.appendChild(td);
				}
				tbody.appendChild(tr);
			}
			
			table.appendChild(thead);
			table.appendChild(tbody);
			table.setAttribute("class","tab");
			
			document.getElementById(locationName).appendChild(table);
		}
	},
	sumUp : function(position,sumData,isShowItemByColumn){
		var tablebody = document.getElementById("charttable_body");
		var size = sumData.length;
		if(isShowItemByColumn){//按列显示表项，按行显示时间
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			td.appendChild(document.createTextNode("合计"));
			tr.appendChild(td);
			for(var i=0;i<size;i++){
				var td = document.createElement("td");
				td.appendChild(document.createTextNode(sumData[i]));
				tr.appendChild(td);
			}
			if(position=="head"){
				tablebody.insertBefore(tr,tablebody.firstChild);
			}else if(position=="tail"){
				tablebody.appendChild(tr);
			}
		}else{
			if(position=="head"){
				var tablehead = document.getElementById("charttable_head");
				var td = document.createElement("td");
				td.appendChild(document.createTextNode("合计"));
				tablehead.firstChild.insertBefore(td,tablehead.firstChild.firstChild.nextSibling);
				var row = tablebody.firstChild;
				for(var i=0;i<size;i++){
					var td = document.createElement("td");
					td.appendChild(document.createTextNode(sumData[i]));
					row.insertBefore(td,row.firstChild.nextSibling);
					row = row.nextSibling;
				}
			}else if(position=="tail"){
				var tablehead = document.getElementById("charttable_head");
				var td = document.createElement("td");
				td.appendChild(document.createTextNode("合计"));
				tablehead.appendChild(td);
				var row = tablebody.firstChild;
				for(var i=0;i<size;i++){
					var td = document.createElement("td");
					td.appendChild(document.createTextNode(sumData[i]));
					row.appendChild(td);
					row = row.nextSibling;
				}
			}
		}
	}
};
